from utils.read import get_data


def process_test_data(raw_data):
    """处理原始测试数据并补全默认值"""
    processed = []
    for item in raw_data:
        default_values = {
            'app_id': '649d02b64f5a460008bfa4ac',
            'entry_id': '',
            'sql': '',
            'fields': 'None',
            'months': 1,
            'name': '未命名测试用例'
        }
        merged_item = {**default_values, **item}
        if not merged_item['entry_id']:
            raise ValueError("entry_id为必填参数，请检查测试数据配置")
        if not merged_item['sql']:
            raise ValueError("sql查询语句为必填参数，请检查测试数据配置")
        processed.append((
            merged_item['app_id'],
            merged_item['entry_id'],
            merged_item['sql'],
            merged_item['fields'],
            merged_item['months'],
            merged_item['name']
        ))
    return processed


def get_test_data():
    raw_data = get_data.read_data('data.yaml')["equipment_system"]
    return process_test_data(raw_data)
